/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
define(["mini/weavee/BaseObject", "text!mini/weavee/Label.html", "mini/weavee/label/LabelModel"], function(BaseObject, UI, LabelModel) {
    return function() {
        var parent = new BaseObject(UI);
        jQuery.extend(this, parent);

        this.model = new LabelModel();
        /**
         * 
         * @param {type} _model instance of mini/weavee/DataGridModel
         * @returns {undefined}
         */
        this.setModel = function(_model) {
            this.model = _model;
        }
        this.getModel = function() {
            return this.model;
        }
        this.repaint = function() {
            var txUI=$(this.ui).find("._label_").get(0);
            if (this.model) {
                $(txUI).val(this.model.getValue());
            }
            if (this.model.getBindingText()) {
                $(txUI).attr("mini:text", this.model.getBindingText());
            }
            if (this.model.getBindingValue()) {
                $(txUI).attr("mini:text", this.model.getBindingValue());
            }
            if (this.model.getMiniModelName()) {
                $(txUI).attr("mini:model", this.model.getMiniModelName());
            }
            $(txUI).attr("mini:object", "data[0]");
            //parent.repaint();
        }
        
        this.setValue=function(_value){
            if(this.model){
                this.model.setValue(_value);
            }
        }
        
        this.getValue=function(){
            if(this.model){
                return this.model.getValue();
            }else{
                return null;
            }
        }
        return this;
    }
});
